




import { Controller } from 'egg';

export default class HomeController extends Controller {
    public async index() {
        const { ctx } = this;
        ctx.body = await ctx.service.test.sayHi('egg');
    }


    // 私人FM
    public async fm() {
        const data = {};
        const url = `/weapi/v1/radio/get`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
    // 喜欢音乐
    public async like(){
        const {id,like,alg,time}=this.ctx.query;
        const data = {
            trackId:id,
            like:like === undefined?  true:like
        }
        const url = `/weapi/radio/like?alg=${alg}&trackId=${id}&like=${like}&time=${time}`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
    // 从私人FM中移到垃圾桶
    public async fmtrash(){
        const {id,time}=this.ctx.query;
        const data = {
            songId:id
        };
        const url = `/weapi/radio/trash/add?alg=RT&songId=${id}&time=${time}`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
}

